package cn.rlfit.gulimall.product.service.impl;

import cn.rlfit.common.utils.PageUtils;
import cn.rlfit.common.utils.Query;
import cn.rlfit.gulimall.product.dao.BrandDao;
import cn.rlfit.gulimall.product.entity.BrandEntity;
import cn.rlfit.gulimall.product.service.BrandService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service("brandService")
public class BrandServiceImpl extends ServiceImpl<BrandDao, BrandEntity> implements BrandService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<BrandEntity> page = this.page(
                new Query<BrandEntity>().getPage(params),
                new QueryWrapper<BrandEntity>()
        );

        return new PageUtils(page);
    }

    /**
     * 根据key进行模糊查询
     * @param key
     * @return
     */
    @Autowired
    BrandDao brandDao;
    @Override
    public List<BrandEntity> queryKey(String key) {
        QueryWrapper<BrandEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.like("name", key);
         return brandDao.selectList(queryWrapper);
    }

}